<template>
  <!-- 标题 -->
  <div class="title">饮食习惯调查表</div>

  <!-- 个人信息表格 -->
  <table>
    <thead>
      <tr>
        <th colspan="4">个人信息</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>姓名：{{ personInfo?.name || "-" }}</td>
        <td>性别：{{ personInfo?.gender || "-" }}</td>
        <td>年龄：{{ personInfo?.age || "-" }}</td>
        <td>门诊号：{{ personInfo?.outpatientNum || "-" }}</td>
      </tr>
      <tr>
        <td>科室：{{ personInfo?.department || "-" }}</td>
        <td>身高：{{ personInfo?.height || "-" }}</td>
        <td>体重：{{ personInfo?.weight || "-" }}</td>
        <td>BMI：{{ personInfo?.bmi || "-" }}</td>
      </tr>
    </tbody>
  </table>

  <!-- 饮食习惯调查表格 -->
  <table>
    <thead>
      <tr>
        <th colspan="2">饮食习惯调查</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td colspan="2">
          <div class="question-item">
            <span class="question-number">1.</span>
            平素是否对动物性蛋白过敏，如肉蛋奶？
            <div class="radio-group">
              <label class="radio-option">
                <input
                  type="radio"
                  name="q1"
                  value="是"
                  :checked="surveyData?.q1 === '是'"
                />
                是
              </label>
              <label class="radio-option">
                <input
                  type="radio"
                  name="q1"
                  value="否"
                  :checked="surveyData?.q1 === '否'"
                />
                否
              </label>
            </div>
          </div>

          <div class="question-item">
            <span class="question-number">2.</span>
            近一周内，每日水果摄入量是否可以达到200g以上？
            <div class="radio-group">
              <label class="radio-option">
                <input
                  type="radio"
                  name="q2"
                  value="是"
                  :checked="surveyData?.q2 === '是'"
                />
                是
              </label>
              <label class="radio-option">
                <input
                  type="radio"
                  name="q2"
                  value="否"
                  :checked="surveyData?.q2 === '否'"
                />
                否
              </label>
            </div>
          </div>

          <div class="question-item">
            <span class="question-number">3.</span>
            近一周，每日肉类摄入量是否能达到50g？
            <div class="radio-group">
              <label class="radio-option">
                <input
                  type="radio"
                  name="q3"
                  value="是"
                  :checked="surveyData?.q3 === '是'"
                />
                是
              </label>
              <label class="radio-option">
                <input
                  type="radio"
                  name="q3"
                  value="否"
                  :checked="surveyData?.q3 === '否'"
                />
                否
              </label>
            </div>
          </div>

          <div class="question-item">
            <span class="question-number">4.</span>
            近一周，每日是否能摄入一个鸡蛋？
            <div class="radio-group">
              <label class="radio-option">
                <input
                  type="radio"
                  name="q4"
                  value="是"
                  :checked="surveyData?.q4 === '是'"
                />
                是
              </label>
              <label class="radio-option">
                <input
                  type="radio"
                  name="q4"
                  value="否"
                  :checked="surveyData?.q4 === '否'"
                />
                否
              </label>
            </div>
          </div>

          <div class="question-item">
            <span class="question-number">5.</span>
            近一周，每日是否能饮用250ml牛奶？
            <div class="radio-group">
              <label class="radio-option">
                <input
                  type="radio"
                  name="q5"
                  value="是"
                  :checked="surveyData?.q5 === '是'"
                />
                是
              </label>
              <label class="radio-option">
                <input
                  type="radio"
                  name="q5"
                  value="否"
                  :checked="surveyData?.q5 === '否'"
                />
                否
              </label>
            </div>
          </div>

          <div class="question-item">
            <span class="question-number">6.</span>
            每日液体量是否能达到2500ml（饮水量与静脉输入量）？
            <div class="radio-group">
              <label class="radio-option">
                <input
                  type="radio"
                  name="q6"
                  value="是"
                  :checked="surveyData?.q6 === '是'"
                />
                是
              </label>
              <label class="radio-option">
                <input
                  type="radio"
                  name="q6"
                  value="否"
                  :checked="surveyData?.q6 === '否'"
                />
                否
              </label>
            </div>
          </div>
        </td>
      </tr>
    </tbody>
  </table>

  <!-- 结果表格 -->
  <table>
    <thead>
      <tr>
        <th>结果</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>{{ result?.advice || "-" }}</td>
      </tr>
    </tbody>
  </table>

  <!-- page-break 分页 -->
  <table class="page-break">
    <tbody>
      <tr>
        <td>医生/护士：{{ footerInfo?.doctor || "-" }}</td>
        <td>日期：{{ footerInfo?.date || new Date().toLocaleString() }}</td>
      </tr>
    </tbody>
  </table>
</template>
<script lang="ts" setup>
defineProps({
  personInfo: {
    type: Object,
    default: () => ({}),
  },
  surveyData: {
    type: Object,
    default: () => ({}),
  },
  result: {
    type: Object,
    default: () => ({}),
  },
  footerInfo: {
    type: Object,
    default: () => ({}),
  },
});
</script>
<style lang="scss" scoped>
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 容器样式 */
.print-container {
  width: 100%;
  max-width: 210mm;
  margin: 0 auto;
  font-family: "SimHei", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  color: #000000;
  line-height: 1.5;
}

/* 标题样式 */
.title {
  text-align: center;
  font-size: 7mm;
  font-weight: bold;
  margin-bottom: 10mm;
}

/* 表格样式 */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: -1px;
  th,
  td {
    border: 1px solid #000;
    padding: 2mm;
    text-align: left;
    vertical-align: top;
  }

  th {
    background-color: #f9f9f9;
    font-weight: bold;
  }
}

/* 问题项样式 */
.question-item {
  margin-bottom: 2mm;
  padding: 2mm 0;
}

.question-number {
  font-weight: bold;
}

/* 单选框样式 */
.radio-group {
  display: flex;
  align-items: center;
  margin-top: 2mm;
}

.radio-option {
  margin-right: 10mm;
  display: flex;
  align-items: center;
  input {
    margin-right: 2mm;
  }
}

/* 打印媒体查询 */
@media print {
  body {
    background: white;
  }

  .print-container {
    box-shadow: none;
  }
}
</style>
